package com.inspire.ijc.agent.utils;

import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

/**
 * @author ：inspire
 * @date ：Created in 2023/4/17 10:07
 * @description：
 * @modified By：inspire
 * @version:
 */
public class ASMUtiils implements Opcodes {

    public static void visitInsn(MethodVisitor mv, int num){
        switch (num){
            case 0:
                mv.visitInsn(ICONST_0);
                break;
            case 1:
                mv.visitInsn(ICONST_1);
                break;
            case 2:
                mv.visitInsn(ICONST_2);
                break;
            case 3:
                mv.visitInsn(ICONST_3);
                break;
            case 4:
                mv.visitInsn(ICONST_4);
                break;
            case 5:
                mv.visitInsn(ICONST_5);
                break;
            default:
                if(num<=127){
                    mv.visitIntInsn(BIPUSH, num);
                }else{
                    mv.visitIntInsn(SIPUSH, num);
                }
        }
    }
}
